<?php

namespace App\Models\Def;

use App\Models\Conf\Site;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Notifications\Notifiable;

use App\Models\Inf\Player;

class MainGamePlat extends Model
{
    use Notifiable;


    public $table = 'def_main_game_plats';

    const CREATED_AT = 'created_at';

    const UPDATED_AT = 'updated_at';

    public $guarded = [];


    public static $rules = [];

    public function Players()
    {
        return $this->hasMany(Player::class, 'main_game_plats_id', 'id');
    }

    public function scopeStatus($query)
    {
        return $query->where('status', 1);
    }

    public function site()
    {
        return $this->belongsToMany(Site::class, 'conf_site_main_game_plats', 'main_game_plats_id', 'site_id');
    }


    public function line()
    {
        return collect(config('game.' . $this->main_game_plat_code . '.line'))
            ->map(function ($item) {
               return collect($item)->only(['default', 'lineName'])->toArray();
            }
            )
            ->toArray();
    }
}
